{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "<table style=\"float:left; border:none\">\n",
    "   <tr style=\"border:none; background-color: #ffffff\">\n",
    "       <td style=\"border:none\">\n",
    "           <a href=\"http://bokeh.pydata.org/\">     \n",
    "           <img \n",
    "               src=\"assets/bokeh-transparent.png\" \n",
    "               style=\"width:50px\"\n",
    "           >\n",
    "           </a>    \n",
    "       </td>\n",
    "       <td style=\"border:none\">\n",
    "           <h1>Bokeh教程</h1>\n",
    "       </td>\n",
    "   </tr>\n",
    "</table>\n",
    "\n",
    "<div style=\"float:right;\"><h2>01. 基本绘图</h2></div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这个章节主要讲解 [`bokeh.plotting`](http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html) \n",
    "接口。这个接口是一个 \"mid-level\" 接口，主要思想如下描述：\n",
    "\n",
    "**从简单的默认图表开始（使用合理的默认工具、网格和轴），添加标记和其他视觉属性直接与数据绑定的图形。**\n",
    "\n",
    "我们将看到我们可以定制和更改所有默认值，但是使用默认值可以很快地把例子运行起来。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 导入和设置\n",
    "\n",
    "使用 [`bokeh.plotting`](http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html) 接口的时候，我们需要导入一些通用模块：\n",
    "* 使用 [`figure`](http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.figure) 函数创建plot对象。\n",
    "* 调用函数 [`output_file`](http://bokeh.pydata.org/en/latest/docs/reference/resources_embedding.html#bokeh.io.output_file), [`output_notebook`](http://bokeh.pydata.org/en/latest/docs/reference/resources_embedding.html#bokeh.io.output_notebook), and [`output_server`](http://bokeh.pydata.org/en/latest/docs/reference/resources_embedding.html#bokeh.io.output_server) （可以组合使用）告诉 Bokeh 如何显示或者保存输出。\n",
    "* 执行 [`show`](http://bokeh.pydata.org/en/latest/docs/reference/resources_embedding.html#bokeh.io.show) 和  [`save`](http://bokeh.pydata.org/en/latest/docs/reference/resources_embedding.html#bokeh.io.save) 显示或者保存图表。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from bokeh.io import output_notebook, show\n",
    "from bokeh.plotting import figure"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "现在，我们在Jupyter notebook里调用 `output_notebook()`。我们只需要调用一次，然后所有后续对 `show()` 的调用都会在Notebook里内嵌显示。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"https://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"6c5925db-4165-484e-9130-469b3952f090\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(root) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  var force = true;\n",
       "\n",
       "  if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "    root._bokeh_onload_callbacks = [];\n",
       "    root._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "\n",
       "  \n",
       "  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    root._bokeh_timeout = Date.now() + 5000;\n",
       "    root._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    if (root.Bokeh !== undefined) {\n",
       "      var el = document.getElementById(\"6c5925db-4165-484e-9130-469b3952f090\");\n",
       "      if (el != null) {\n",
       "        el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n",
       "      }\n",
       "    } else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "\n",
       "  function run_callbacks() {\n",
       "    try {\n",
       "      root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "    }\n",
       "    finally {\n",
       "      delete root._bokeh_onload_callbacks\n",
       "    }\n",
       "    console.info(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(js_urls, callback) {\n",
       "    root._bokeh_onload_callbacks.push(callback);\n",
       "    if (root._bokeh_is_loading > 0) {\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    root._bokeh_is_loading = js_urls.length;\n",
       "    for (var i = 0; i < js_urls.length; i++) {\n",
       "      var url = js_urls[i];\n",
       "      var s = document.createElement('script');\n",
       "      s.src = url;\n",
       "      s.async = false;\n",
       "      s.onreadystatechange = s.onload = function() {\n",
       "        root._bokeh_is_loading--;\n",
       "        if (root._bokeh_is_loading === 0) {\n",
       "          console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "          run_callbacks()\n",
       "        }\n",
       "      };\n",
       "      s.onerror = function() {\n",
       "        console.warn(\"failed to load library \" + url);\n",
       "      };\n",
       "      console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "  };var element = document.getElementById(\"6c5925db-4165-484e-9130-469b3952f090\");\n",
       "  if (element == null) {\n",
       "    console.log(\"Bokeh: ERROR: autoload.js configured with elementid '6c5925db-4165-484e-9130-469b3952f090' but no matching script tag was found. \")\n",
       "    return false;\n",
       "  }\n",
       "\n",
       "  var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.7.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.7.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.7.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.7.min.js\"];\n",
       "\n",
       "  var inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    \n",
       "    function(Bokeh) {\n",
       "      \n",
       "    },\n",
       "    \n",
       "    function(Bokeh) {\n",
       "      \n",
       "      document.getElementById(\"6c5925db-4165-484e-9130-469b3952f090\").textContent = \"BokehJS is loading...\";\n",
       "    },\n",
       "    function(Bokeh) {\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.7.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.7.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.7.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.7.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.7.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.7.min.css\");\n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if ((root.Bokeh !== undefined) || (force === true)) {\n",
       "      for (var i = 0; i < inline_js.length; i++) {\n",
       "        inline_js[i].call(root, root.Bokeh);\n",
       "      }if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!root._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      root._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      var cell = $(document.getElementById(\"6c5925db-4165-484e-9130-469b3952f090\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (root._bokeh_is_loading === 0) {\n",
       "    console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(js_urls, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(window));"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "output_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 基本的散点图\n",
    "\n",
    "这一节，你将会看到如何使用Bokeh的各种标记来创建简单的散点图。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <div class=\"bk-plotdiv\" id=\"fded8efb-f5ce-4e47-baca-1ea6255fc8c8\"></div>\n",
       "    </div>\n",
       "<script type=\"text/javascript\">\n",
       "  \n",
       "  (function(root) {\n",
       "    function now() {\n",
       "      return new Date();\n",
       "    }\n",
       "  \n",
       "    var force = false;\n",
       "  \n",
       "    if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "      root._bokeh_onload_callbacks = [];\n",
       "      root._bokeh_is_loading = undefined;\n",
       "    }\n",
       "  \n",
       "  \n",
       "    \n",
       "    if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "      root._bokeh_timeout = Date.now() + 0;\n",
       "      root._bokeh_failed_load = false;\n",
       "    }\n",
       "  \n",
       "    var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "       \"<div style='background-color: #fdd'>\\n\"+\n",
       "       \"<p>\\n\"+\n",
       "       \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "       \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "       \"</p>\\n\"+\n",
       "       \"<ul>\\n\"+\n",
       "       \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "       \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "       \"</ul>\\n\"+\n",
       "       \"<code>\\n\"+\n",
       "       \"from bokeh.resources import INLINE\\n\"+\n",
       "       \"output_notebook(resources=INLINE)\\n\"+\n",
       "       \"</code>\\n\"+\n",
       "       \"</div>\"}};\n",
       "  \n",
       "    function display_loaded() {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        var el = document.getElementById(\"fded8efb-f5ce-4e47-baca-1ea6255fc8c8\");\n",
       "        if (el != null) {\n",
       "          el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n",
       "        }\n",
       "      } else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(display_loaded, 100)\n",
       "      }\n",
       "    }\n",
       "  \n",
       "  \n",
       "    function run_callbacks() {\n",
       "      try {\n",
       "        root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "      }\n",
       "      finally {\n",
       "        delete root._bokeh_onload_callbacks\n",
       "      }\n",
       "      console.info(\"Bokeh: all callbacks have finished\");\n",
       "    }\n",
       "  \n",
       "    function load_libs(js_urls, callback) {\n",
       "      root._bokeh_onload_callbacks.push(callback);\n",
       "      if (root._bokeh_is_loading > 0) {\n",
       "        console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "        return null;\n",
       "      }\n",
       "      if (js_urls == null || js_urls.length === 0) {\n",
       "        run_callbacks();\n",
       "        return null;\n",
       "      }\n",
       "      console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "      root._bokeh_is_loading = js_urls.length;\n",
       "      for (var i = 0; i < js_urls.length; i++) {\n",
       "        var url = js_urls[i];\n",
       "        var s = document.createElement('script');\n",
       "        s.src = url;\n",
       "        s.async = false;\n",
       "        s.onreadystatechange = s.onload = function() {\n",
       "          root._bokeh_is_loading--;\n",
       "          if (root._bokeh_is_loading === 0) {\n",
       "            console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "            run_callbacks()\n",
       "          }\n",
       "        };\n",
       "        s.onerror = function() {\n",
       "          console.warn(\"failed to load library \" + url);\n",
       "        };\n",
       "        console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      }\n",
       "    };var element = document.getElementById(\"fded8efb-f5ce-4e47-baca-1ea6255fc8c8\");\n",
       "    if (element == null) {\n",
       "      console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'fded8efb-f5ce-4e47-baca-1ea6255fc8c8' but no matching script tag was found. \")\n",
       "      return false;\n",
       "    }\n",
       "  \n",
       "    var js_urls = [];\n",
       "  \n",
       "    var inline_js = [\n",
       "      function(Bokeh) {\n",
       "        (function() {\n",
       "          var fn = function() {\n",
       "            var docs_json = {\"756e2b16-ff50-45e1-92a9-6884ec4c5b40\":{\"roots\":{\"references\":[{\"attributes\":{},\"id\":\"ccef090c-e5a0-4fc7-bade-3444ea993ab8\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"below\":[{\"id\":\"b2a22ffb-f3c4-4bf3-822d-5eccc708b33a\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"d36d7a50-6dd7-4a3c-943f-be275532593c\",\"type\":\"LinearAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"b2a22ffb-f3c4-4bf3-822d-5eccc708b33a\",\"type\":\"LinearAxis\"},{\"id\":\"76064f59-d623-4a83-bbc6-3a91ea44c92b\",\"type\":\"Grid\"},{\"id\":\"d36d7a50-6dd7-4a3c-943f-be275532593c\",\"type\":\"LinearAxis\"},{\"id\":\"21be0bca-fceb-4121-94da-c5205ffb21ee\",\"type\":\"Grid\"},{\"id\":\"1143ab4b-3768-4797-8153-052fe31910ff\",\"type\":\"BoxAnnotation\"},{\"id\":\"56a15554-7954-47eb-b774-3278e3da6e83\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"1f590bfc-d5d8-4579-bc70-6e96913172a2\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"7e3f1393-c969-4ae6-adbc-c66335e43c00\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"98c29fcf-052d-47fb-a95c-22147d887c8b\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"413416c4-b07f-4fcc-b36c-9212982799f7\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"d7b66369-2cc0-4297-8e22-b18d2276ec7c\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"38ceb7f1-a742-4937-8f1f-bcd9daf3a453\",\"type\":\"LinearScale\"}},\"id\":\"e38c372e-c5a9-463c-958e-673b4447f160\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1,2,3,4,5],\"y\":[6,7,2,4,5]}},\"id\":\"3bd5825c-c58c-4262-93f1-e627cd32a7db\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1143ab4b-3768-4797-8153-052fe31910ff\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"5403e395-7f57-4e27-9195-04498134670d\",\"type\":\"PanTool\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"5403e395-7f57-4e27-9195-04498134670d\",\"type\":\"PanTool\"},{\"id\":\"057dff30-dc25-448a-8e24-cce185a14266\",\"type\":\"WheelZoomTool\"},{\"id\":\"373da021-b8b7-44da-b7ed-767f8c973618\",\"type\":\"BoxZoomTool\"},{\"id\":\"cc7bc8b6-1ae2-412f-9582-83285a6ab20e\",\"type\":\"SaveTool\"},{\"id\":\"07ec41ca-e897-4bb1-814c-aea13f8b44a0\",\"type\":\"ResetTool\"},{\"id\":\"d2656da5-11c0-456e-a9b4-8b04588da972\",\"type\":\"HelpTool\"}]},\"id\":\"7e3f1393-c969-4ae6-adbc-c66335e43c00\",\"type\":\"Toolbar\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"units\":\"screen\",\"value\":15},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"048c418c-8595-4e26-a19f-febb983d2bd7\",\"type\":\"Circle\"},{\"attributes\":{\"callback\":null},\"id\":\"98c29fcf-052d-47fb-a95c-22147d887c8b\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"057dff30-dc25-448a-8e24-cce185a14266\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"overlay\":{\"id\":\"1143ab4b-3768-4797-8153-052fe31910ff\",\"type\":\"BoxAnnotation\"}},\"id\":\"373da021-b8b7-44da-b7ed-767f8c973618\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"callback\":null},\"id\":\"d7b66369-2cc0-4297-8e22-b18d2276ec7c\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"cc7bc8b6-1ae2-412f-9582-83285a6ab20e\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"413416c4-b07f-4fcc-b36c-9212982799f7\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"07ec41ca-e897-4bb1-814c-aea13f8b44a0\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"38ceb7f1-a742-4937-8f1f-bcd9daf3a453\",\"type\":\"LinearScale\"},{\"attributes\":{\"data_source\":{\"id\":\"3bd5825c-c58c-4262-93f1-e627cd32a7db\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"3f05bb6b-9d47-41e1-97ba-70ee017e1563\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"048c418c-8595-4e26-a19f-febb983d2bd7\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"28b0be1b-019e-469b-89bc-af803d8be686\",\"type\":\"CDSView\"}},\"id\":\"56a15554-7954-47eb-b774-3278e3da6e83\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"d2656da5-11c0-456e-a9b4-8b04588da972\",\"type\":\"HelpTool\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"orange\"},\"line_color\":{\"value\":\"navy\"},\"size\":{\"units\":\"screen\",\"value\":15},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"3f05bb6b-9d47-41e1-97ba-70ee017e1563\",\"type\":\"Circle\"},{\"attributes\":{\"formatter\":{\"id\":\"ccef090c-e5a0-4fc7-bade-3444ea993ab8\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"e38c372e-c5a9-463c-958e-673b4447f160\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"601dc1f3-f7d2-4800-8796-6ec6f993e368\",\"type\":\"BasicTicker\"}},\"id\":\"b2a22ffb-f3c4-4bf3-822d-5eccc708b33a\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"601dc1f3-f7d2-4800-8796-6ec6f993e368\",\"type\":\"BasicTicker\"},{\"attributes\":{\"plot\":{\"id\":\"e38c372e-c5a9-463c-958e-673b4447f160\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"601dc1f3-f7d2-4800-8796-6ec6f993e368\",\"type\":\"BasicTicker\"}},\"id\":\"76064f59-d623-4a83-bbc6-3a91ea44c92b\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"0d25e765-ef72-4395-b0f1-2c154b6dd396\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"e38c372e-c5a9-463c-958e-673b4447f160\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"8658e09b-f3c4-44cd-960d-93672cc646f5\",\"type\":\"BasicTicker\"}},\"id\":\"d36d7a50-6dd7-4a3c-943f-be275532593c\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"8658e09b-f3c4-44cd-960d-93672cc646f5\",\"type\":\"BasicTicker\"},{\"attributes\":{\"source\":{\"id\":\"3bd5825c-c58c-4262-93f1-e627cd32a7db\",\"type\":\"ColumnDataSource\"}},\"id\":\"28b0be1b-019e-469b-89bc-af803d8be686\",\"type\":\"CDSView\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"e38c372e-c5a9-463c-958e-673b4447f160\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"8658e09b-f3c4-44cd-960d-93672cc646f5\",\"type\":\"BasicTicker\"}},\"id\":\"21be0bca-fceb-4121-94da-c5205ffb21ee\",\"type\":\"Grid\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"1f590bfc-d5d8-4579-bc70-6e96913172a2\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"0d25e765-ef72-4395-b0f1-2c154b6dd396\",\"type\":\"BasicTickFormatter\"}],\"root_ids\":[\"e38c372e-c5a9-463c-958e-673b4447f160\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.7\"}};\n",
       "            var render_items = [{\"docid\":\"756e2b16-ff50-45e1-92a9-6884ec4c5b40\",\"elementid\":\"fded8efb-f5ce-4e47-baca-1ea6255fc8c8\",\"modelid\":\"e38c372e-c5a9-463c-958e-673b4447f160\"}];\n",
       "            \n",
       "            Bokeh.embed.embed_items(docs_json, render_items);\n",
       "          };\n",
       "          if (document.readyState != \"loading\") fn();\n",
       "          else document.addEventListener(\"DOMContentLoaded\", fn);\n",
       "        })();\n",
       "      },\n",
       "      function(Bokeh) {\n",
       "      }\n",
       "    ];\n",
       "  \n",
       "    function run_inline_js() {\n",
       "      \n",
       "      if ((root.Bokeh !== undefined) || (force === true)) {\n",
       "        for (var i = 0; i < inline_js.length; i++) {\n",
       "          inline_js[i].call(root, root.Bokeh);\n",
       "        }if (force === true) {\n",
       "          display_loaded();\n",
       "        }} else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(run_inline_js, 100);\n",
       "      } else if (!root._bokeh_failed_load) {\n",
       "        console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "        root._bokeh_failed_load = true;\n",
       "      } else if (force !== true) {\n",
       "        var cell = $(document.getElementById(\"fded8efb-f5ce-4e47-baca-1ea6255fc8c8\")).parents('.cell').data().cell;\n",
       "        cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "      }\n",
       "  \n",
       "    }\n",
       "  \n",
       "    if (root._bokeh_is_loading === 0) {\n",
       "      console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "      run_inline_js();\n",
       "    } else {\n",
       "      load_libs(js_urls, function() {\n",
       "        console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "        run_inline_js();\n",
       "      });\n",
       "    }\n",
       "  }(window));\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# create a new plot with default tools, using figure\n",
    "p = figure(plot_width=400, plot_height=400)\n",
    "\n",
    "# add a circle renderer with a size, color, and alpha\n",
    "p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=15, line_color=\"navy\", fill_color=\"orange\", fill_alpha=0.5)\n",
    "\n",
    "show(p) # show the results"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "所有的Bokeh标记都具有 `size` 属性（屏幕空间单元？？？）。Circles 还具有 `radius` 属性（\"data\" 空间单元？？？）。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# EXERCISE: Try changing the example above to set a `radius` value instead of `size`\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "为了散列正方形标记而不是圆，你可以对figure对象使用 `square` 方法。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <div class=\"bk-plotdiv\" id=\"e52c4535-de3e-466e-b8bb-32848663aee0\"></div>\n",
       "    </div>\n",
       "<script type=\"text/javascript\">\n",
       "  \n",
       "  (function(root) {\n",
       "    function now() {\n",
       "      return new Date();\n",
       "    }\n",
       "  \n",
       "    var force = false;\n",
       "  \n",
       "    if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "      root._bokeh_onload_callbacks = [];\n",
       "      root._bokeh_is_loading = undefined;\n",
       "    }\n",
       "  \n",
       "  \n",
       "    \n",
       "    if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "      root._bokeh_timeout = Date.now() + 0;\n",
       "      root._bokeh_failed_load = false;\n",
       "    }\n",
       "  \n",
       "    var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "       \"<div style='background-color: #fdd'>\\n\"+\n",
       "       \"<p>\\n\"+\n",
       "       \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "       \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "       \"</p>\\n\"+\n",
       "       \"<ul>\\n\"+\n",
       "       \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "       \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "       \"</ul>\\n\"+\n",
       "       \"<code>\\n\"+\n",
       "       \"from bokeh.resources import INLINE\\n\"+\n",
       "       \"output_notebook(resources=INLINE)\\n\"+\n",
       "       \"</code>\\n\"+\n",
       "       \"</div>\"}};\n",
       "  \n",
       "    function display_loaded() {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        var el = document.getElementById(\"e52c4535-de3e-466e-b8bb-32848663aee0\");\n",
       "        if (el != null) {\n",
       "          el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n",
       "        }\n",
       "      } else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(display_loaded, 100)\n",
       "      }\n",
       "    }\n",
       "  \n",
       "  \n",
       "    function run_callbacks() {\n",
       "      try {\n",
       "        root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "      }\n",
       "      finally {\n",
       "        delete root._bokeh_onload_callbacks\n",
       "      }\n",
       "      console.info(\"Bokeh: all callbacks have finished\");\n",
       "    }\n",
       "  \n",
       "    function load_libs(js_urls, callback) {\n",
       "      root._bokeh_onload_callbacks.push(callback);\n",
       "      if (root._bokeh_is_loading > 0) {\n",
       "        console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "        return null;\n",
       "      }\n",
       "      if (js_urls == null || js_urls.length === 0) {\n",
       "        run_callbacks();\n",
       "        return null;\n",
       "      }\n",
       "      console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "      root._bokeh_is_loading = js_urls.length;\n",
       "      for (var i = 0; i < js_urls.length; i++) {\n",
       "        var url = js_urls[i];\n",
       "        var s = document.createElement('script');\n",
       "        s.src = url;\n",
       "        s.async = false;\n",
       "        s.onreadystatechange = s.onload = function() {\n",
       "          root._bokeh_is_loading--;\n",
       "          if (root._bokeh_is_loading === 0) {\n",
       "            console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "            run_callbacks()\n",
       "          }\n",
       "        };\n",
       "        s.onerror = function() {\n",
       "          console.warn(\"failed to load library \" + url);\n",
       "        };\n",
       "        console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      }\n",
       "    };var element = document.getElementById(\"e52c4535-de3e-466e-b8bb-32848663aee0\");\n",
       "    if (element == null) {\n",
       "      console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'e52c4535-de3e-466e-b8bb-32848663aee0' but no matching script tag was found. \")\n",
       "      return false;\n",
       "    }\n",
       "  \n",
       "    var js_urls = [];\n",
       "  \n",
       "    var inline_js = [\n",
       "      function(Bokeh) {\n",
       "        (function() {\n",
       "          var fn = function() {\n",
       "            var docs_json = {\"f13344ac-f033-4fa8-b892-dc921abea744\":{\"roots\":{\"references\":[{\"attributes\":{\"source\":{\"id\":\"b1da0e5f-ff2b-407d-b51b-ed5e678d35a0\",\"type\":\"ColumnDataSource\"}},\"id\":\"fb9e3464-74a8-4dd5-8fa0-77751d4cd862\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"b0d6aaa1-e398-4a39-b081-27d4a79524fe\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"e0b99e6d-5382-41c9-8df7-beabea04d743\",\"type\":\"ResetTool\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"field\":\"size\",\"units\":\"screen\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"30b50d06-1131-4bd5-865b-cf6a4ad7da57\",\"type\":\"Square\"},{\"attributes\":{},\"id\":\"9bcad6b5-e4c9-4b6a-91d6-1a5ed9ce966c\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"formatter\":{\"id\":\"df94bba9-19ba-4397-a5ec-36f1c62e80e9\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"9c47b18b-54d6-40b4-8be1-2f4fda2e69d7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"b417e07a-a9fa-4381-a6c9-3c63f6aa8259\",\"type\":\"BasicTicker\"}},\"id\":\"2e30dbce-48d4-443f-bffe-3ea674bda3bc\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"4da92100-b49d-4cc1-b2b0-3409e33e3efe\",\"type\":\"BasicTicker\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"a036b11a-bddb-4399-b9ba-5ff5024168f1\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"cc57e5e2-63a5-45bb-9966-bca0f81c531d\",\"type\":\"HelpTool\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.6},\"fill_color\":{\"value\":\"firebrick\"},\"line_alpha\":{\"value\":0.6},\"line_color\":{\"value\":\"firebrick\"},\"size\":{\"field\":\"size\",\"units\":\"screen\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"c2002854-70fe-487b-8f7d-87240008befa\",\"type\":\"Square\"},{\"attributes\":{},\"id\":\"b417e07a-a9fa-4381-a6c9-3c63f6aa8259\",\"type\":\"BasicTicker\"},{\"attributes\":{\"below\":[{\"id\":\"120eabfd-be07-42dc-9a34-dc3cfc92cf09\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"2e30dbce-48d4-443f-bffe-3ea674bda3bc\",\"type\":\"LinearAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"120eabfd-be07-42dc-9a34-dc3cfc92cf09\",\"type\":\"LinearAxis\"},{\"id\":\"2f4a9b29-00d6-41ab-b37f-e6649b278447\",\"type\":\"Grid\"},{\"id\":\"2e30dbce-48d4-443f-bffe-3ea674bda3bc\",\"type\":\"LinearAxis\"},{\"id\":\"39874312-6f98-4826-a3f4-87bdfd91c436\",\"type\":\"Grid\"},{\"id\":\"a036b11a-bddb-4399-b9ba-5ff5024168f1\",\"type\":\"BoxAnnotation\"},{\"id\":\"bc15add2-76a3-4b39-b51f-3529a21b211f\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"15df282e-ca82-49ad-9aa2-3cc5b0f24c59\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"9b99408d-ea6d-42fd-a62c-bd751fc82af0\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"2e4d329b-c685-4e4f-900e-88afbfb19a0f\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"c91883ae-2b1b-4b31-9a02-aaf4431dc937\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"3403aac2-28a9-41eb-88e1-9d30ce7c9c27\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"b0d6aaa1-e398-4a39-b081-27d4a79524fe\",\"type\":\"LinearScale\"}},\"id\":\"9c47b18b-54d6-40b4-8be1-2f4fda2e69d7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"df94bba9-19ba-4397-a5ec-36f1c62e80e9\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"c91883ae-2b1b-4b31-9a02-aaf4431dc937\",\"type\":\"LinearScale\"},{\"attributes\":{\"overlay\":{\"id\":\"a036b11a-bddb-4399-b9ba-5ff5024168f1\",\"type\":\"BoxAnnotation\"}},\"id\":\"580f00f2-10f2-4d5c-a65b-f3f9b82df154\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"plot\":{\"id\":\"9c47b18b-54d6-40b4-8be1-2f4fda2e69d7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4da92100-b49d-4cc1-b2b0-3409e33e3efe\",\"type\":\"BasicTicker\"}},\"id\":\"2f4a9b29-00d6-41ab-b37f-e6649b278447\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\",\"size\"],\"data\":{\"size\":[10,15,20,25,30],\"x\":[1,2,3,4,5],\"y\":[6,7,2,4,5]}},\"id\":\"b1da0e5f-ff2b-407d-b51b-ed5e678d35a0\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"344ac323-e98b-4eb4-aa75-7c83581dd03a\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"formatter\":{\"id\":\"344ac323-e98b-4eb4-aa75-7c83581dd03a\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"9c47b18b-54d6-40b4-8be1-2f4fda2e69d7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4da92100-b49d-4cc1-b2b0-3409e33e3efe\",\"type\":\"BasicTicker\"}},\"id\":\"120eabfd-be07-42dc-9a34-dc3cfc92cf09\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null},\"id\":\"3403aac2-28a9-41eb-88e1-9d30ce7c9c27\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"46d6a42f-7462-42f5-ae36-9dcc5b3a6277\",\"type\":\"PanTool\"},{\"attributes\":{\"data_source\":{\"id\":\"b1da0e5f-ff2b-407d-b51b-ed5e678d35a0\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"c2002854-70fe-487b-8f7d-87240008befa\",\"type\":\"Square\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"30b50d06-1131-4bd5-865b-cf6a4ad7da57\",\"type\":\"Square\"},\"selection_glyph\":null,\"view\":{\"id\":\"fb9e3464-74a8-4dd5-8fa0-77751d4cd862\",\"type\":\"CDSView\"}},\"id\":\"bc15add2-76a3-4b39-b51f-3529a21b211f\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"9c47b18b-54d6-40b4-8be1-2f4fda2e69d7\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"b417e07a-a9fa-4381-a6c9-3c63f6aa8259\",\"type\":\"BasicTicker\"}},\"id\":\"39874312-6f98-4826-a3f4-87bdfd91c436\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null},\"id\":\"2e4d329b-c685-4e4f-900e-88afbfb19a0f\",\"type\":\"DataRange1d\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"15df282e-ca82-49ad-9aa2-3cc5b0f24c59\",\"type\":\"Title\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"46d6a42f-7462-42f5-ae36-9dcc5b3a6277\",\"type\":\"PanTool\"},{\"id\":\"9bcad6b5-e4c9-4b6a-91d6-1a5ed9ce966c\",\"type\":\"WheelZoomTool\"},{\"id\":\"580f00f2-10f2-4d5c-a65b-f3f9b82df154\",\"type\":\"BoxZoomTool\"},{\"id\":\"d57967d9-f0eb-48ff-aecb-18b1acd48756\",\"type\":\"SaveTool\"},{\"id\":\"e0b99e6d-5382-41c9-8df7-beabea04d743\",\"type\":\"ResetTool\"},{\"id\":\"cc57e5e2-63a5-45bb-9966-bca0f81c531d\",\"type\":\"HelpTool\"}]},\"id\":\"9b99408d-ea6d-42fd-a62c-bd751fc82af0\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"d57967d9-f0eb-48ff-aecb-18b1acd48756\",\"type\":\"SaveTool\"}],\"root_ids\":[\"9c47b18b-54d6-40b4-8be1-2f4fda2e69d7\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.7\"}};\n",
       "            var render_items = [{\"docid\":\"f13344ac-f033-4fa8-b892-dc921abea744\",\"elementid\":\"e52c4535-de3e-466e-b8bb-32848663aee0\",\"modelid\":\"9c47b18b-54d6-40b4-8be1-2f4fda2e69d7\"}];\n",
       "            \n",
       "            Bokeh.embed.embed_items(docs_json, render_items);\n",
       "          };\n",
       "          if (document.readyState != \"loading\") fn();\n",
       "          else document.addEventListener(\"DOMContentLoaded\", fn);\n",
       "        })();\n",
       "      },\n",
       "      function(Bokeh) {\n",
       "      }\n",
       "    ];\n",
       "  \n",
       "    function run_inline_js() {\n",
       "      \n",
       "      if ((root.Bokeh !== undefined) || (force === true)) {\n",
       "        for (var i = 0; i < inline_js.length; i++) {\n",
       "          inline_js[i].call(root, root.Bokeh);\n",
       "        }if (force === true) {\n",
       "          display_loaded();\n",
       "        }} else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(run_inline_js, 100);\n",
       "      } else if (!root._bokeh_failed_load) {\n",
       "        console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "        root._bokeh_failed_load = true;\n",
       "      } else if (force !== true) {\n",
       "        var cell = $(document.getElementById(\"e52c4535-de3e-466e-b8bb-32848663aee0\")).parents('.cell').data().cell;\n",
       "        cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "      }\n",
       "  \n",
       "    }\n",
       "  \n",
       "    if (root._bokeh_is_loading === 0) {\n",
       "      console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "      run_inline_js();\n",
       "    } else {\n",
       "      load_libs(js_urls, function() {\n",
       "        console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "        run_inline_js();\n",
       "      });\n",
       "    }\n",
       "  }(window));\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# create a new plot using figure\n",
    "p = figure(plot_width=400, plot_height=400)\n",
    "\n",
    "# add a square renderer with a size, color, alpha, and sizes\n",
    "p.square([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=[10, 15, 20, 25, 30], color=\"firebrick\", alpha=0.6)\n",
    "\n",
    "show(p) # show the results"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "注意，在上面的例子中，我们还为每个标记指定不同的大小。 ***一般来说，所有标记符号的属性都可以通过这种形式 \"向量化\" 。*** 还要注意的是，我们通过 ``color`` 参数同时设置了线条和填充颜色。这是 ``bokeh.plotting`` 的一个特殊便利用法。\n",
    "\n",
    "</table><p>Bokeh有很多标记类型，你可以点击以下参考手册中的条目\n",
    "来了解更多细节和例子：</p>\n",
    "<table class=\"hlist\" style=\"float:left\"><tr><td><ul>\n",
    "<li><a href=\"http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.Figure.asterisk\" title=\"bokeh.plotting.Figure.asterisk\"><code class=\"xref py py-func docutils literal\"><span class=\"pre\">asterisk()</span></code></a></li>\n",
    "<li><a href=\"http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.Figure.circle\" title=\"bokeh.plotting.Figure.circle\"><code class=\"xref py py-func docutils literal\"><span class=\"pre\">circle()</span></code></a></li>\n",
    "<li><a href=\"http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.Figure.circle_cross\" title=\"bokeh.plotting.Figure.circle_cross\"><code class=\"xref py py-func docutils literal\"><span class=\"pre\">circle_cross()</span></code></a></li>\n",
    "<li><a href=\"http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.Figure.circle_x\" title=\"bokeh.plotting.Figure.circle_x\"><code class=\"xref py py-func docutils literal\"><span class=\"pre\">circle_x()</span></code></a></li>\n",
    "<li><a href=\"http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.Figure.cross\" title=\"bokeh.plotting.Figure.cross\"><code class=\"xref py py-func docutils literal\"><span class=\"pre\">cross()</span></code></a></li>\n",
    "</ul>\n",
    "</td><td><ul>\n",
    "<li><a href=\"http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.Figure.diamond\" title=\"bokeh.plotting.Figure.diamond\"><code class=\"xref py py-func docutils literal\"><span class=\"pre\">diamond()</span></code></a></li>\n",
    "<li><a href=\"http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.Figure.diamond_cross\" title=\"bokeh.plotting.Figure.diamond_cross\"><code class=\"xref py py-func docutils literal\"><span class=\"pre\">diamond_cross()</span></code></a></li>\n",
    "<li><a href=\"http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.Figure.inverted_triangle\" title=\"bokeh.plotting.Figure.inverted_triangle\"><code class=\"xref py py-func docutils literal\"><span class=\"pre\">inverted_triangle()</span></code></a></li>\n",
    "<li><a href=\"http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.Figure.square\" title=\"bokeh.plotting.Figure.square\"><code class=\"xref py py-func docutils literal\"><span class=\"pre\">square()</span></code></a></li>\n",
    "</ul>\n",
    "</td><td><ul>\n",
    "<li><a href=\"http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.Figure.square_cross\" title=\"bokeh.plotting.Figure.square_cross\"><code class=\"xref py py-func docutils literal\"><span class=\"pre\">square_cross()</span></code></a></li>\n",
    "<li><a href=\"http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.Figure.square_x\" title=\"bokeh.plotting.Figure.square_x\"><code class=\"xref py py-func docutils literal\"><span class=\"pre\">square_x()</span></code></a></li>\n",
    "<li><a href=\"http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.Figure.triangle\" title=\"bokeh.plotting.Figure.triangle\"><code class=\"xref py py-func docutils literal\"><span class=\"pre\">triangle()</span></code></a></li>\n",
    "<li><a href=\"http://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.Figure.x\" title=\"bokeh.plotting.Figure.x\"><code class=\"xref py py-func docutils literal\"><span class=\"pre\">x()</span></code></a></li>\n",
    "</ul>\n",
    "</td></tr></table>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# EXERCISE: Plot some different markers in this cell\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 基本线形图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <div class=\"bk-plotdiv\" id=\"e34e546c-f0a2-4c68-a406-9bb87dc61a0f\"></div>\n",
       "    </div>\n",
       "<script type=\"text/javascript\">\n",
       "  \n",
       "  (function(root) {\n",
       "    function now() {\n",
       "      return new Date();\n",
       "    }\n",
       "  \n",
       "    var force = false;\n",
       "  \n",
       "    if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "      root._bokeh_onload_callbacks = [];\n",
       "      root._bokeh_is_loading = undefined;\n",
       "    }\n",
       "  \n",
       "  \n",
       "    \n",
       "    if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "      root._bokeh_timeout = Date.now() + 0;\n",
       "      root._bokeh_failed_load = false;\n",
       "    }\n",
       "  \n",
       "    var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "       \"<div style='background-color: #fdd'>\\n\"+\n",
       "       \"<p>\\n\"+\n",
       "       \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "       \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "       \"</p>\\n\"+\n",
       "       \"<ul>\\n\"+\n",
       "       \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "       \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "       \"</ul>\\n\"+\n",
       "       \"<code>\\n\"+\n",
       "       \"from bokeh.resources import INLINE\\n\"+\n",
       "       \"output_notebook(resources=INLINE)\\n\"+\n",
       "       \"</code>\\n\"+\n",
       "       \"</div>\"}};\n",
       "  \n",
       "    function display_loaded() {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        var el = document.getElementById(\"e34e546c-f0a2-4c68-a406-9bb87dc61a0f\");\n",
       "        if (el != null) {\n",
       "          el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n",
       "        }\n",
       "      } else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(display_loaded, 100)\n",
       "      }\n",
       "    }\n",
       "  \n",
       "  \n",
       "    function run_callbacks() {\n",
       "      try {\n",
       "        root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "      }\n",
       "      finally {\n",
       "        delete root._bokeh_onload_callbacks\n",
       "      }\n",
       "      console.info(\"Bokeh: all callbacks have finished\");\n",
       "    }\n",
       "  \n",
       "    function load_libs(js_urls, callback) {\n",
       "      root._bokeh_onload_callbacks.push(callback);\n",
       "      if (root._bokeh_is_loading > 0) {\n",
       "        console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "        return null;\n",
       "      }\n",
       "      if (js_urls == null || js_urls.length === 0) {\n",
       "        run_callbacks();\n",
       "        return null;\n",
       "      }\n",
       "      console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "      root._bokeh_is_loading = js_urls.length;\n",
       "      for (var i = 0; i < js_urls.length; i++) {\n",
       "        var url = js_urls[i];\n",
       "        var s = document.createElement('script');\n",
       "        s.src = url;\n",
       "        s.async = false;\n",
       "        s.onreadystatechange = s.onload = function() {\n",
       "          root._bokeh_is_loading--;\n",
       "          if (root._bokeh_is_loading === 0) {\n",
       "            console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "            run_callbacks()\n",
       "          }\n",
       "        };\n",
       "        s.onerror = function() {\n",
       "          console.warn(\"failed to load library \" + url);\n",
       "        };\n",
       "        console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      }\n",
       "    };var element = document.getElementById(\"e34e546c-f0a2-4c68-a406-9bb87dc61a0f\");\n",
       "    if (element == null) {\n",
       "      console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'e34e546c-f0a2-4c68-a406-9bb87dc61a0f' but no matching script tag was found. \")\n",
       "      return false;\n",
       "    }\n",
       "  \n",
       "    var js_urls = [];\n",
       "  \n",
       "    var inline_js = [\n",
       "      function(Bokeh) {\n",
       "        (function() {\n",
       "          var fn = function() {\n",
       "            var docs_json = {\"4181f3f4-2df4-47c4-8e9d-60be4e5bab3e\":{\"roots\":{\"references\":[{\"attributes\":{},\"id\":\"6274297e-e538-4c46-955b-41e44cf79c72\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"1f8d281a-cc7f-4133-a62e-cf4543b85813\",\"type\":\"BasicTicker\"},{\"attributes\":{\"callback\":null},\"id\":\"86bf0b36-307c-4eea-aa76-1286aa0ff0e8\",\"type\":\"DataRange1d\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"b5236b5a-995b-4589-8125-a3b85940631c\",\"type\":\"PanTool\"},{\"id\":\"6274297e-e538-4c46-955b-41e44cf79c72\",\"type\":\"WheelZoomTool\"},{\"id\":\"5b65afec-8279-442d-bc05-603488ebdbff\",\"type\":\"BoxZoomTool\"},{\"id\":\"c569de2c-e985-4190-9f33-bdbcec128efd\",\"type\":\"SaveTool\"},{\"id\":\"868e8f63-19b9-43af-8abe-a2126c02a896\",\"type\":\"ResetTool\"},{\"id\":\"cd6c48b5-ab2a-4ed8-9e63-f8f9d8ec1bf1\",\"type\":\"HelpTool\"}]},\"id\":\"d67a9654-4a1d-4d26-90cf-8315bb11edfe\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"7d5ef425-d2a8-4d40-8e32-b7cfa31e6828\",\"type\":\"BasicTicker\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"line_width\":{\"value\":2},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"9a12b47a-2af2-40b8-9147-f7f76daf8f24\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"ab3d0768-32d7-4fdf-846f-60338e2721d2\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"cd6c48b5-ab2a-4ed8-9e63-f8f9d8ec1bf1\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"5fa31464-22c7-418e-8360-563e2e93350e\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"plot\":null,\"text\":\"My Line Plot\"},\"id\":\"7ffe7c3d-d921-4aea-a032-63da3e648253\",\"type\":\"Title\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"a8b5b5c2-1f82-4b92-86d7-254840ed1776\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1f8d281a-cc7f-4133-a62e-cf4543b85813\",\"type\":\"BasicTicker\"}},\"id\":\"39e09496-9d4d-4a16-91e8-3fde91282039\",\"type\":\"Grid\"},{\"attributes\":{\"below\":[{\"id\":\"f8158e6e-df93-43c1-b0a2-1d28b42ebf6d\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"4144f5f7-5171-4d95-980e-d19ad4d933cb\",\"type\":\"LinearAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"f8158e6e-df93-43c1-b0a2-1d28b42ebf6d\",\"type\":\"LinearAxis\"},{\"id\":\"875fc852-7e09-4031-bef0-05feb3942243\",\"type\":\"Grid\"},{\"id\":\"4144f5f7-5171-4d95-980e-d19ad4d933cb\",\"type\":\"LinearAxis\"},{\"id\":\"39e09496-9d4d-4a16-91e8-3fde91282039\",\"type\":\"Grid\"},{\"id\":\"8b5d4d97-ec8e-4ace-bcb8-b3a384ef6e58\",\"type\":\"BoxAnnotation\"},{\"id\":\"1173bdc0-d3f2-400e-a973-df870a87ab23\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"7ffe7c3d-d921-4aea-a032-63da3e648253\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"d67a9654-4a1d-4d26-90cf-8315bb11edfe\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"86bf0b36-307c-4eea-aa76-1286aa0ff0e8\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"6e798ad9-914c-42dc-8a0c-a5039b23602a\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"31e05458-ef8d-4d83-bf92-cc7242d3380e\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"ab3d0768-32d7-4fdf-846f-60338e2721d2\",\"type\":\"LinearScale\"}},\"id\":\"a8b5b5c2-1f82-4b92-86d7-254840ed1776\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"formatter\":{\"id\":\"9ec54a8a-f328-4a12-8071-efa08bc41fd4\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"a8b5b5c2-1f82-4b92-86d7-254840ed1776\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"7d5ef425-d2a8-4d40-8e32-b7cfa31e6828\",\"type\":\"BasicTicker\"}},\"id\":\"f8158e6e-df93-43c1-b0a2-1d28b42ebf6d\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null},\"id\":\"31e05458-ef8d-4d83-bf92-cc7242d3380e\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"b5236b5a-995b-4589-8125-a3b85940631c\",\"type\":\"PanTool\"},{\"attributes\":{\"formatter\":{\"id\":\"5fa31464-22c7-418e-8360-563e2e93350e\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"a8b5b5c2-1f82-4b92-86d7-254840ed1776\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1f8d281a-cc7f-4133-a62e-cf4543b85813\",\"type\":\"BasicTicker\"}},\"id\":\"4144f5f7-5171-4d95-980e-d19ad4d933cb\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"868e8f63-19b9-43af-8abe-a2126c02a896\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"c569de2c-e985-4190-9f33-bdbcec128efd\",\"type\":\"SaveTool\"},{\"attributes\":{\"plot\":{\"id\":\"a8b5b5c2-1f82-4b92-86d7-254840ed1776\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"7d5ef425-d2a8-4d40-8e32-b7cfa31e6828\",\"type\":\"BasicTicker\"}},\"id\":\"875fc852-7e09-4031-bef0-05feb3942243\",\"type\":\"Grid\"},{\"attributes\":{\"line_color\":{\"value\":\"#1f77b4\"},\"line_width\":{\"value\":2},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"f5fa1cdf-5911-4045-882c-fb69e026f68a\",\"type\":\"Line\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1,2,3,4,5],\"y\":[6,7,2,4,5]}},\"id\":\"87958a0b-2ece-4fdb-8e3b-b07a8565d300\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"data_source\":{\"id\":\"87958a0b-2ece-4fdb-8e3b-b07a8565d300\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"f5fa1cdf-5911-4045-882c-fb69e026f68a\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"9a12b47a-2af2-40b8-9147-f7f76daf8f24\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"9a87bd66-bf07-4728-a4d9-e3d461900aa5\",\"type\":\"CDSView\"}},\"id\":\"1173bdc0-d3f2-400e-a973-df870a87ab23\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"source\":{\"id\":\"87958a0b-2ece-4fdb-8e3b-b07a8565d300\",\"type\":\"ColumnDataSource\"}},\"id\":\"9a87bd66-bf07-4728-a4d9-e3d461900aa5\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"9ec54a8a-f328-4a12-8071-efa08bc41fd4\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"overlay\":{\"id\":\"8b5d4d97-ec8e-4ace-bcb8-b3a384ef6e58\",\"type\":\"BoxAnnotation\"}},\"id\":\"5b65afec-8279-442d-bc05-603488ebdbff\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"6e798ad9-914c-42dc-8a0c-a5039b23602a\",\"type\":\"LinearScale\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"8b5d4d97-ec8e-4ace-bcb8-b3a384ef6e58\",\"type\":\"BoxAnnotation\"}],\"root_ids\":[\"a8b5b5c2-1f82-4b92-86d7-254840ed1776\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.7\"}};\n",
       "            var render_items = [{\"docid\":\"4181f3f4-2df4-47c4-8e9d-60be4e5bab3e\",\"elementid\":\"e34e546c-f0a2-4c68-a406-9bb87dc61a0f\",\"modelid\":\"a8b5b5c2-1f82-4b92-86d7-254840ed1776\"}];\n",
       "            \n",
       "            Bokeh.embed.embed_items(docs_json, render_items);\n",
       "          };\n",
       "          if (document.readyState != \"loading\") fn();\n",
       "          else document.addEventListener(\"DOMContentLoaded\", fn);\n",
       "        })();\n",
       "      },\n",
       "      function(Bokeh) {\n",
       "      }\n",
       "    ];\n",
       "  \n",
       "    function run_inline_js() {\n",
       "      \n",
       "      if ((root.Bokeh !== undefined) || (force === true)) {\n",
       "        for (var i = 0; i < inline_js.length; i++) {\n",
       "          inline_js[i].call(root, root.Bokeh);\n",
       "        }if (force === true) {\n",
       "          display_loaded();\n",
       "        }} else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(run_inline_js, 100);\n",
       "      } else if (!root._bokeh_failed_load) {\n",
       "        console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "        root._bokeh_failed_load = true;\n",
       "      } else if (force !== true) {\n",
       "        var cell = $(document.getElementById(\"e34e546c-f0a2-4c68-a406-9bb87dc61a0f\")).parents('.cell').data().cell;\n",
       "        cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "      }\n",
       "  \n",
       "    }\n",
       "  \n",
       "    if (root._bokeh_is_loading === 0) {\n",
       "      console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "      run_inline_js();\n",
       "    } else {\n",
       "      load_libs(js_urls, function() {\n",
       "        console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "        run_inline_js();\n",
       "      });\n",
       "    }\n",
       "  }(window));\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# create a new plot (with a title) using figure\n",
    "p = figure(plot_width=400, plot_height=400, title=\"My Line Plot\")\n",
    "\n",
    "# add a line renderer\n",
    "p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2)\n",
    "\n",
    "show(p) # show the results"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 图画"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "下面这个例子展示如何使用 `image_rgba` 方法显示原始RGBA数据。\n",
    "\n",
    "**注意**：这个例子使用了NumPy库"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <div class=\"bk-plotdiv\" id=\"c96724a6-5305-421e-9c19-94bcf4bbaf59\"></div>\n",
       "    </div>\n",
       "<script type=\"text/javascript\">\n",
       "  \n",
       "  (function(root) {\n",
       "    function now() {\n",
       "      return new Date();\n",
       "    }\n",
       "  \n",
       "    var force = false;\n",
       "  \n",
       "    if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "      root._bokeh_onload_callbacks = [];\n",
       "      root._bokeh_is_loading = undefined;\n",
       "    }\n",
       "  \n",
       "  \n",
       "    \n",
       "    if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "      root._bokeh_timeout = Date.now() + 0;\n",
       "      root._bokeh_failed_load = false;\n",
       "    }\n",
       "  \n",
       "    var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "       \"<div style='background-color: #fdd'>\\n\"+\n",
       "       \"<p>\\n\"+\n",
       "       \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "       \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "       \"</p>\\n\"+\n",
       "       \"<ul>\\n\"+\n",
       "       \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "       \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "       \"</ul>\\n\"+\n",
       "       \"<code>\\n\"+\n",
       "       \"from bokeh.resources import INLINE\\n\"+\n",
       "       \"output_notebook(resources=INLINE)\\n\"+\n",
       "       \"</code>\\n\"+\n",
       "       \"</div>\"}};\n",
       "  \n",
       "    function display_loaded() {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        var el = document.getElementById(\"c96724a6-5305-421e-9c19-94bcf4bbaf59\");\n",
       "        if (el != null) {\n",
       "          el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n",
       "        }\n",
       "      } else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(display_loaded, 100)\n",
       "      }\n",
       "    }\n",
       "  \n",
       "  \n",
       "    function run_callbacks() {\n",
       "      try {\n",
       "        root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "      }\n",
       "      finally {\n",
       "        delete root._bokeh_onload_callbacks\n",
       "      }\n",
       "      console.info(\"Bokeh: all callbacks have finished\");\n",
       "    }\n",
       "  \n",
       "    function load_libs(js_urls, callback) {\n",
       "      root._bokeh_onload_callbacks.push(callback);\n",
       "      if (root._bokeh_is_loading > 0) {\n",
       "        console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "        return null;\n",
       "      }\n",
       "      if (js_urls == null || js_urls.length === 0) {\n",
       "        run_callbacks();\n",
       "        return null;\n",
       "      }\n",
       "      console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "      root._bokeh_is_loading = js_urls.length;\n",
       "      for (var i = 0; i < js_urls.length; i++) {\n",
       "        var url = js_urls[i];\n",
       "        var s = document.createElement('script');\n",
       "        s.src = url;\n",
       "        s.async = false;\n",
       "        s.onreadystatechange = s.onload = function() {\n",
       "          root._bokeh_is_loading--;\n",
       "          if (root._bokeh_is_loading === 0) {\n",
       "            console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "            run_callbacks()\n",
       "          }\n",
       "        };\n",
       "        s.onerror = function() {\n",
       "          console.warn(\"failed to load library \" + url);\n",
       "        };\n",
       "        console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      }\n",
       "    };var element = document.getElementById(\"c96724a6-5305-421e-9c19-94bcf4bbaf59\");\n",
       "    if (element == null) {\n",
       "      console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'c96724a6-5305-421e-9c19-94bcf4bbaf59' but no matching script tag was found. \")\n",
       "      return false;\n",
       "    }\n",
       "  \n",
       "    var js_urls = [];\n",
       "  \n",
       "    var inline_js = [\n",
       "      function(Bokeh) {\n",
       "        (function() {\n",
       "          var fn = function() {\n",
       "            var docs_json = {\"628d17d9-4d1f-451f-8998-687959f66253\":{\"roots\":{\"references\":[{\"attributes\":{},\"id\":\"da6840b9-920b-4be8-8c28-19a16cb13941\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"0fa24b7e-ed53-4ff9-85be-595ca83716e5\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"data_source\":{\"id\":\"7ba72a5d-4153-4e4a-a99e-be18bc2c4f91\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"c924a465-635f-4c8c-b18a-c161a1118e64\",\"type\":\"ImageRGBA\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"dac27ef9-4f6e-43d5-9200-052b3d4d6250\",\"type\":\"ImageRGBA\"},\"selection_glyph\":null,\"view\":{\"id\":\"e4efe5f6-66dc-40c5-a9d8-c3f85d15c090\",\"type\":\"CDSView\"}},\"id\":\"0d9845ac-18dc-4b2b-b709-a131e5c58808\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"source\":{\"id\":\"7ba72a5d-4153-4e4a-a99e-be18bc2c4f91\",\"type\":\"ColumnDataSource\"}},\"id\":\"e4efe5f6-66dc-40c5-a9d8-c3f85d15c090\",\"type\":\"CDSView\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"a5c8b60a-8cc6-4d64-a432-876d6552bec2\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"0feea8c4-1367-4b57-9a4e-a6b2f1103e3e\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"image\",\"x\",\"y\",\"dw\",\"dh\"],\"data\":{\"dh\":[10],\"dw\":[10],\"image\":[{\"__ndarray__\":\"AJ4A/wCeDP8Anhn/AJ4m/wCeM/8Anj//AJ5M/wCeWf8Anmb/AJ5y/wCef/8Anoz/AJ6Z/wCepf8AnrL/AJ6//wCezP8Antj/AJ7l/wCe8v8MngD/DJ4M/wyeGf8Mnib/DJ4z/wyeP/8Mnkz/DJ5Z/wyeZv8MnnL/DJ5//wyejP8Mnpn/DJ6l/wyesv8Mnr//DJ7M/wye2P8MnuX/DJ7y/xmeAP8Zngz/GZ4Z/xmeJv8ZnjP/GZ4//xmeTP8Znln/GZ5m/xmecv8Znn//GZ6M/xmemf8ZnqX/GZ6y/xmev/8Znsz/GZ7Y/xme5f8ZnvL/Jp4A/yaeDP8mnhn/Jp4m/yaeM/8mnj//Jp5M/yaeWf8mnmb/Jp5y/yaef/8mnoz/Jp6Z/yaepf8mnrL/Jp6//yaezP8mntj/Jp7l/yae8v8zngD/M54M/zOeGf8znib/M54z/zOeP/8znkz/M55Z/zOeZv8znnL/M55//zOejP8znpn/M56l/zOesv8znr//M57M/zOe2P8znuX/M57y/z+eAP8/ngz/P54Z/z+eJv8/njP/P54//z+eTP8/nln/P55m/z+ecv8/nn//P56M/z+emf8/nqX/P56y/z+ev/8/nsz/P57Y/z+e5f8/nvL/TJ4A/0yeDP9Mnhn/TJ4m/0yeM/9Mnj//TJ5M/0yeWf9Mnmb/TJ5y/0yef/9Mnoz/TJ6Z/0yepf9MnrL/TJ6//0yezP9Mntj/TJ7l/0ye8v9ZngD/WZ4M/1meGf9Znib/WZ4z/1meP/9Znkz/WZ5Z/1meZv9ZnnL/WZ5//1mejP9Znpn/WZ6l/1mesv9Znr//WZ7M/1me2P9ZnuX/WZ7y/2aeAP9mngz/Zp4Z/2aeJv9mnjP/Zp4//2aeTP9mnln/Zp5m/2aecv9mnn//Zp6M/2aemf9mnqX/Zp6y/2aev/9mnsz/Zp7Y/2ae5f9mnvL/cp4A/3KeDP9ynhn/cp4m/3KeM/9ynj//cp5M/3KeWf9ynmb/cp5y/3Kef/9ynoz/cp6Z/3Kepf9ynrL/cp6//3KezP9yntj/cp7l/3Ke8v9/ngD/f54M/3+eGf9/nib/f54z/3+eP/9/nkz/f55Z/3+eZv9/nnL/f55//3+ejP9/npn/f56l/3+esv9/nr//f57M/3+e2P9/nuX/f57y/4yeAP+Mngz/jJ4Z/4yeJv+MnjP/jJ4//4yeTP+Mnln/jJ5m/4yecv+Mnn//jJ6M/4yemf+MnqX/jJ6y/4yev/+Mnsz/jJ7Y/4ye5f+MnvL/mZ4A/5meDP+Znhn/mZ4m/5meM/+Znj//mZ5M/5meWf+Znmb/mZ5y/5mef/+Znoz/mZ6Z/5mepf+ZnrL/mZ6//5mezP+Zntj/mZ7l/5me8v+lngD/pZ4M/6WeGf+lnib/pZ4z/6WeP/+lnkz/pZ5Z/6WeZv+lnnL/pZ5//6WejP+lnpn/pZ6l/6Wesv+lnr//pZ7M/6We2P+lnuX/pZ7y/7KeAP+yngz/sp4Z/7KeJv+ynjP/sp4//7KeTP+ynln/sp5m/7Kecv+ynn//sp6M/7Kemf+ynqX/sp6y/7Kev/+ynsz/sp7Y/7Ke5f+ynvL/v54A/7+eDP+/nhn/v54m/7+eM/+/nj//v55M/7+eWf+/nmb/v55y/7+ef/+/noz/v56Z/7+epf+/nrL/v56//7+ezP+/ntj/v57l/7+e8v/MngD/zJ4M/8yeGf/Mnib/zJ4z/8yeP//Mnkz/zJ5Z/8yeZv/MnnL/zJ5//8yejP/Mnpn/zJ6l/8yesv/Mnr//zJ7M/8ye2P/MnuX/zJ7y/9ieAP/Yngz/2J4Z/9ieJv/YnjP/2J4//9ieTP/Ynln/2J5m/9iecv/Ynn//2J6M/9iemf/YnqX/2J6y/9iev//Ynsz/2J7Y/9ie5f/YnvL/5Z4A/+WeDP/lnhn/5Z4m/+WeM//lnj//5Z5M/+WeWf/lnmb/5Z5y/+Wef//lnoz/5Z6Z/+Wepf/lnrL/5Z6//+WezP/lntj/5Z7l/+We8v/yngD/8p4M//KeGf/ynib/8p4z//KeP//ynkz/8p5Z//KeZv/ynnL/8p5///KejP/ynpn/8p6l//Kesv/ynr//8p7M//Ke2P/ynuX/8p7y/w==\",\"dtype\":\"uint32\",\"shape\":[20,20]}],\"x\":[0],\"y\":[0]}},\"id\":\"7ba72a5d-4153-4e4a-a99e-be18bc2c4f91\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"99442e0a-2580-45aa-a30f-38a69f329f74\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"below\":[{\"id\":\"c231630c-3b81-4d36-a128-bd33c39d589a\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"8118f531-6ebd-4577-93c1-ddf0853fb564\",\"type\":\"LinearAxis\"}],\"renderers\":[{\"id\":\"c231630c-3b81-4d36-a128-bd33c39d589a\",\"type\":\"LinearAxis\"},{\"id\":\"282ac633-5e32-41c4-9702-937a2beda87c\",\"type\":\"Grid\"},{\"id\":\"8118f531-6ebd-4577-93c1-ddf0853fb564\",\"type\":\"LinearAxis\"},{\"id\":\"3036584f-62e3-4c01-b9dc-fd2488230821\",\"type\":\"Grid\"},{\"id\":\"99442e0a-2580-45aa-a30f-38a69f329f74\",\"type\":\"BoxAnnotation\"},{\"id\":\"0d9845ac-18dc-4b2b-b709-a131e5c58808\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"a5c8b60a-8cc6-4d64-a432-876d6552bec2\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"ac89d9a9-261c-4d57-a346-0b136736c999\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"b8b42ee5-ca46-4b96-aeff-c529e97f310a\",\"type\":\"Range1d\"},\"x_scale\":{\"id\":\"6abfbc1f-6404-483f-9fed-b7cb2ad936eb\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"418c23ae-86b8-4c67-8334-4b4c3618e8a4\",\"type\":\"Range1d\"},\"y_scale\":{\"id\":\"d6f8b38a-d101-446b-bddb-5bad7ee49315\",\"type\":\"LinearScale\"}},\"id\":\"b75e8fb8-5e6e-4d51-90d2-ccb9da10fb12\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1d4c2b45-42dc-4d94-a4c6-a33b94e863aa\",\"type\":\"PanTool\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1d4c2b45-42dc-4d94-a4c6-a33b94e863aa\",\"type\":\"PanTool\"},{\"id\":\"5e6d8fe9-8b0c-43df-baa8-84b62cc0d0b4\",\"type\":\"WheelZoomTool\"},{\"id\":\"d20bdc20-bbf2-4610-ace9-ab27da946b91\",\"type\":\"BoxZoomTool\"},{\"id\":\"041fab7d-9b44-4af5-bf55-ce4de0b761a6\",\"type\":\"SaveTool\"},{\"id\":\"edbe4197-5eac-4bf0-868b-68aabb550505\",\"type\":\"ResetTool\"},{\"id\":\"6758c58c-85e2-4c5d-aa87-86935bbef8d3\",\"type\":\"HelpTool\"}]},\"id\":\"ac89d9a9-261c-4d57-a346-0b136736c999\",\"type\":\"Toolbar\"},{\"attributes\":{\"callback\":null,\"end\":10},\"id\":\"418c23ae-86b8-4c67-8334-4b4c3618e8a4\",\"type\":\"Range1d\"},{\"attributes\":{},\"id\":\"5e6d8fe9-8b0c-43df-baa8-84b62cc0d0b4\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"dh\":{\"field\":\"dh\",\"units\":\"data\"},\"dw\":{\"field\":\"dw\",\"units\":\"data\"},\"image\":{\"field\":\"image\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"dac27ef9-4f6e-43d5-9200-052b3d4d6250\",\"type\":\"ImageRGBA\"},{\"attributes\":{\"overlay\":{\"id\":\"99442e0a-2580-45aa-a30f-38a69f329f74\",\"type\":\"BoxAnnotation\"}},\"id\":\"d20bdc20-bbf2-4610-ace9-ab27da946b91\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"dh\":{\"field\":\"dh\",\"units\":\"data\"},\"dw\":{\"field\":\"dw\",\"units\":\"data\"},\"image\":{\"field\":\"image\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"c924a465-635f-4c8c-b18a-c161a1118e64\",\"type\":\"ImageRGBA\"},{\"attributes\":{\"callback\":null,\"end\":10},\"id\":\"b8b42ee5-ca46-4b96-aeff-c529e97f310a\",\"type\":\"Range1d\"},{\"attributes\":{},\"id\":\"041fab7d-9b44-4af5-bf55-ce4de0b761a6\",\"type\":\"SaveTool\"},{\"attributes\":{\"formatter\":{\"id\":\"0fa24b7e-ed53-4ff9-85be-595ca83716e5\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"b75e8fb8-5e6e-4d51-90d2-ccb9da10fb12\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"da6840b9-920b-4be8-8c28-19a16cb13941\",\"type\":\"BasicTicker\"}},\"id\":\"8118f531-6ebd-4577-93c1-ddf0853fb564\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"edbe4197-5eac-4bf0-868b-68aabb550505\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"6abfbc1f-6404-483f-9fed-b7cb2ad936eb\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"6758c58c-85e2-4c5d-aa87-86935bbef8d3\",\"type\":\"HelpTool\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"b75e8fb8-5e6e-4d51-90d2-ccb9da10fb12\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"da6840b9-920b-4be8-8c28-19a16cb13941\",\"type\":\"BasicTicker\"}},\"id\":\"3036584f-62e3-4c01-b9dc-fd2488230821\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"d6f8b38a-d101-446b-bddb-5bad7ee49315\",\"type\":\"LinearScale\"},{\"attributes\":{\"plot\":{\"id\":\"b75e8fb8-5e6e-4d51-90d2-ccb9da10fb12\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"dd6c3d9c-9849-403c-aaba-ab5beb5e9ca6\",\"type\":\"BasicTicker\"}},\"id\":\"282ac633-5e32-41c4-9702-937a2beda87c\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"0feea8c4-1367-4b57-9a4e-a6b2f1103e3e\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"b75e8fb8-5e6e-4d51-90d2-ccb9da10fb12\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"dd6c3d9c-9849-403c-aaba-ab5beb5e9ca6\",\"type\":\"BasicTicker\"}},\"id\":\"c231630c-3b81-4d36-a128-bd33c39d589a\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"dd6c3d9c-9849-403c-aaba-ab5beb5e9ca6\",\"type\":\"BasicTicker\"}],\"root_ids\":[\"b75e8fb8-5e6e-4d51-90d2-ccb9da10fb12\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.7\"}};\n",
       "            var render_items = [{\"docid\":\"628d17d9-4d1f-451f-8998-687959f66253\",\"elementid\":\"c96724a6-5305-421e-9c19-94bcf4bbaf59\",\"modelid\":\"b75e8fb8-5e6e-4d51-90d2-ccb9da10fb12\"}];\n",
       "            \n",
       "            Bokeh.embed.embed_items(docs_json, render_items);\n",
       "          };\n",
       "          if (document.readyState != \"loading\") fn();\n",
       "          else document.addEventListener(\"DOMContentLoaded\", fn);\n",
       "        })();\n",
       "      },\n",
       "      function(Bokeh) {\n",
       "      }\n",
       "    ];\n",
       "  \n",
       "    function run_inline_js() {\n",
       "      \n",
       "      if ((root.Bokeh !== undefined) || (force === true)) {\n",
       "        for (var i = 0; i < inline_js.length; i++) {\n",
       "          inline_js[i].call(root, root.Bokeh);\n",
       "        }if (force === true) {\n",
       "          display_loaded();\n",
       "        }} else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(run_inline_js, 100);\n",
       "      } else if (!root._bokeh_failed_load) {\n",
       "        console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "        root._bokeh_failed_load = true;\n",
       "      } else if (force !== true) {\n",
       "        var cell = $(document.getElementById(\"c96724a6-5305-421e-9c19-94bcf4bbaf59\")).parents('.cell').data().cell;\n",
       "        cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "      }\n",
       "  \n",
       "    }\n",
       "  \n",
       "    if (root._bokeh_is_loading === 0) {\n",
       "      console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "      run_inline_js();\n",
       "    } else {\n",
       "      load_libs(js_urls, function() {\n",
       "        console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "        run_inline_js();\n",
       "      });\n",
       "    }\n",
       "  }(window));\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from __future__ import division\n",
    "import numpy as np\n",
    "\n",
    "# set up some data\n",
    "N = 20\n",
    "img = np.empty((N,N), dtype=np.uint32)\n",
    "view = img.view(dtype=np.uint8).reshape((N, N, 4))\n",
    "for i in range(N):\n",
    "    for j in range(N):\n",
    "        view[i, j, 0] = int(i/N*255) # red\n",
    "        view[i, j, 1] = 158          # green\n",
    "        view[i, j, 2] = int(j/N*255) # blue\n",
    "        view[i, j, 3] = 255          # alpha\n",
    "        \n",
    "# create a new plot (with a fixed range) using figure\n",
    "p = figure(x_range=[0,10], y_range=[0,10])\n",
    "\n",
    "# add an RGBA image renderer\n",
    "p.image_rgba(image=[img], x=[0], y=[0], dw=[10], dh=[10])\n",
    "\n",
    "show(p) # show the results"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 其它符号\n",
    "\n",
    "Bokeh支持许多其它标记符号。你可以点击如下用户手册链接来看看如何通过 [`bokeh.plotting`](http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html) 接口用这些标记符号绘制图形。\n",
    "\n",
    "* [矩形和椭圆](http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#rectangles-and-ovals)\n",
    "* [线段和射线](http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#segments-and-rays)\n",
    "* [楔形和弧形](http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#wedges-and-arcs)\n",
    "* [专业的曲线](http://bokeh.pydata.org/en/latest/docs/user_guide/plotting.html#specialized-curves)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# EXERCISE: Plot some of the other glyph types, following the examples in the User Guide. \n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 用多种标记符号绘图 \n",
    "\n",
    "只需要在某个图形对象上调用多个标记方法，在单个图形上可以合并使用多种符号。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <div class=\"bk-plotdiv\" id=\"5af4ccf3-6a1f-4d7b-973a-f8de11deb631\"></div>\n",
       "    </div>\n",
       "<script type=\"text/javascript\">\n",
       "  \n",
       "  (function(root) {\n",
       "    function now() {\n",
       "      return new Date();\n",
       "    }\n",
       "  \n",
       "    var force = false;\n",
       "  \n",
       "    if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "      root._bokeh_onload_callbacks = [];\n",
       "      root._bokeh_is_loading = undefined;\n",
       "    }\n",
       "  \n",
       "  \n",
       "    \n",
       "    if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "      root._bokeh_timeout = Date.now() + 0;\n",
       "      root._bokeh_failed_load = false;\n",
       "    }\n",
       "  \n",
       "    var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "       \"<div style='background-color: #fdd'>\\n\"+\n",
       "       \"<p>\\n\"+\n",
       "       \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "       \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "       \"</p>\\n\"+\n",
       "       \"<ul>\\n\"+\n",
       "       \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "       \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "       \"</ul>\\n\"+\n",
       "       \"<code>\\n\"+\n",
       "       \"from bokeh.resources import INLINE\\n\"+\n",
       "       \"output_notebook(resources=INLINE)\\n\"+\n",
       "       \"</code>\\n\"+\n",
       "       \"</div>\"}};\n",
       "  \n",
       "    function display_loaded() {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        var el = document.getElementById(\"5af4ccf3-6a1f-4d7b-973a-f8de11deb631\");\n",
       "        if (el != null) {\n",
       "          el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n",
       "        }\n",
       "      } else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(display_loaded, 100)\n",
       "      }\n",
       "    }\n",
       "  \n",
       "  \n",
       "    function run_callbacks() {\n",
       "      try {\n",
       "        root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "      }\n",
       "      finally {\n",
       "        delete root._bokeh_onload_callbacks\n",
       "      }\n",
       "      console.info(\"Bokeh: all callbacks have finished\");\n",
       "    }\n",
       "  \n",
       "    function load_libs(js_urls, callback) {\n",
       "      root._bokeh_onload_callbacks.push(callback);\n",
       "      if (root._bokeh_is_loading > 0) {\n",
       "        console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "        return null;\n",
       "      }\n",
       "      if (js_urls == null || js_urls.length === 0) {\n",
       "        run_callbacks();\n",
       "        return null;\n",
       "      }\n",
       "      console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "      root._bokeh_is_loading = js_urls.length;\n",
       "      for (var i = 0; i < js_urls.length; i++) {\n",
       "        var url = js_urls[i];\n",
       "        var s = document.createElement('script');\n",
       "        s.src = url;\n",
       "        s.async = false;\n",
       "        s.onreadystatechange = s.onload = function() {\n",
       "          root._bokeh_is_loading--;\n",
       "          if (root._bokeh_is_loading === 0) {\n",
       "            console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "            run_callbacks()\n",
       "          }\n",
       "        };\n",
       "        s.onerror = function() {\n",
       "          console.warn(\"failed to load library \" + url);\n",
       "        };\n",
       "        console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      }\n",
       "    };var element = document.getElementById(\"5af4ccf3-6a1f-4d7b-973a-f8de11deb631\");\n",
       "    if (element == null) {\n",
       "      console.log(\"Bokeh: ERROR: autoload.js configured with elementid '5af4ccf3-6a1f-4d7b-973a-f8de11deb631' but no matching script tag was found. \")\n",
       "      return false;\n",
       "    }\n",
       "  \n",
       "    var js_urls = [];\n",
       "  \n",
       "    var inline_js = [\n",
       "      function(Bokeh) {\n",
       "        (function() {\n",
       "          var fn = function() {\n",
       "            var docs_json = {\"d99dc78a-e0c8-4975-b7dc-f7a9b0130435\":{\"roots\":{\"references\":[{\"attributes\":{\"formatter\":{\"id\":\"9c2ba828-287a-4500-9346-e5ea24bc76e4\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"0df8d695-d5e7-4c15-be5b-1739152bd2ca\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"0b6b1964-dd18-429d-bd76-cfe487e370b2\",\"type\":\"BasicTicker\"}},\"id\":\"c287bd57-523d-40fd-84ae-4fd6bb58d15e\",\"type\":\"LinearAxis\"},{\"attributes\":{\"fill_color\":{\"value\":\"white\"},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"units\":\"screen\",\"value\":8},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"df90eb0b-1a6d-4e3b-a6d4-b3d0d23c3c2d\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"0b6b1964-dd18-429d-bd76-cfe487e370b2\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"0df8d695-d5e7-4c15-be5b-1739152bd2ca\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"0b6b1964-dd18-429d-bd76-cfe487e370b2\",\"type\":\"BasicTicker\"}},\"id\":\"4a9ae9a3-9bc8-4c25-84ce-7074a1f7bff2\",\"type\":\"Grid\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"line_width\":{\"value\":2},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"b70e6299-5d04-4ce2-9956-515f9803b95d\",\"type\":\"Line\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1,2,3,4,5],\"y\":[6,7,8,7,3]}},\"id\":\"d3d89c33-542e-4b5e-a5f4-3797d2d5894b\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"units\":\"screen\",\"value\":8},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"b0dce9d1-0600-45f5-851c-5e5b052fc0a4\",\"type\":\"Circle\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"e4c2d199-5dae-4146-b6ed-628596c13e56\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"0f8e5eea-7818-4092-8074-3b5b02b34902\",\"type\":\"PanTool\"},{\"attributes\":{\"source\":{\"id\":\"73a58309-751c-4064-b87c-bfc9628d977a\",\"type\":\"ColumnDataSource\"}},\"id\":\"c6bfd093-0612-4257-bbad-af2093ba4774\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"7f5e241b-cc10-4c65-87ee-587cab98dd61\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"overlay\":{\"id\":\"e4c2d199-5dae-4146-b6ed-628596c13e56\",\"type\":\"BoxAnnotation\"}},\"id\":\"f6642516-c84d-452c-8b75-c8a71c026808\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"b93cdc12-0cae-4558-b4de-82258fdeda83\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"11455519-5677-436a-868f-27f4c718dded\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"3d62a331-33d9-4c25-8612-dda893f771f9\",\"type\":\"HelpTool\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"5cc38195-4c01-4a93-8613-b487eec14bf7\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"9c2ba828-287a-4500-9346-e5ea24bc76e4\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1,2,3,4,5],\"y\":[6,7,8,7,3]}},\"id\":\"73a58309-751c-4064-b87c-bfc9628d977a\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"formatter\":{\"id\":\"0b06b4ee-939c-4cce-bb91-7950cf5c218e\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"0df8d695-d5e7-4c15-be5b-1739152bd2ca\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"220070e2-6302-4697-91c1-2dfa316c8841\",\"type\":\"BasicTicker\"}},\"id\":\"caf90238-f255-48dc-935e-3a3129773943\",\"type\":\"LinearAxis\"},{\"attributes\":{\"data_source\":{\"id\":\"73a58309-751c-4064-b87c-bfc9628d977a\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"bbbb5b6b-b2b3-4f7c-a034-ef04284e6932\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"b70e6299-5d04-4ce2-9956-515f9803b95d\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"c6bfd093-0612-4257-bbad-af2093ba4774\",\"type\":\"CDSView\"}},\"id\":\"fc9be6b8-1562-4e66-a962-aba3881064d6\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"plot\":{\"id\":\"0df8d695-d5e7-4c15-be5b-1739152bd2ca\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"220070e2-6302-4697-91c1-2dfa316c8841\",\"type\":\"BasicTicker\"}},\"id\":\"f8c8edb7-4b29-4a27-bd15-7cdaefdb9e63\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"0b06b4ee-939c-4cce-bb91-7950cf5c218e\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"below\":[{\"id\":\"caf90238-f255-48dc-935e-3a3129773943\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"c287bd57-523d-40fd-84ae-4fd6bb58d15e\",\"type\":\"LinearAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"caf90238-f255-48dc-935e-3a3129773943\",\"type\":\"LinearAxis\"},{\"id\":\"f8c8edb7-4b29-4a27-bd15-7cdaefdb9e63\",\"type\":\"Grid\"},{\"id\":\"c287bd57-523d-40fd-84ae-4fd6bb58d15e\",\"type\":\"LinearAxis\"},{\"id\":\"4a9ae9a3-9bc8-4c25-84ce-7074a1f7bff2\",\"type\":\"Grid\"},{\"id\":\"e4c2d199-5dae-4146-b6ed-628596c13e56\",\"type\":\"BoxAnnotation\"},{\"id\":\"fc9be6b8-1562-4e66-a962-aba3881064d6\",\"type\":\"GlyphRenderer\"},{\"id\":\"29c7074f-b8ba-4d79-bbe4-24bc40db2bc9\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"5cc38195-4c01-4a93-8613-b487eec14bf7\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"deba4899-e12c-4557-8251-6e6234942335\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"b9be13f6-6817-4543-9e40-63b9ce192600\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"842c8533-f82d-40dc-917f-c32b50801efd\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"e1b88d03-ee69-4987-b429-d8aac4f348f9\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"b6c999d7-215d-45cd-8031-655c7dcd0e31\",\"type\":\"LinearScale\"}},\"id\":\"0df8d695-d5e7-4c15-be5b-1739152bd2ca\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"0f8e5eea-7818-4092-8074-3b5b02b34902\",\"type\":\"PanTool\"},{\"id\":\"7f5e241b-cc10-4c65-87ee-587cab98dd61\",\"type\":\"WheelZoomTool\"},{\"id\":\"f6642516-c84d-452c-8b75-c8a71c026808\",\"type\":\"BoxZoomTool\"},{\"id\":\"b93cdc12-0cae-4558-b4de-82258fdeda83\",\"type\":\"SaveTool\"},{\"id\":\"11455519-5677-436a-868f-27f4c718dded\",\"type\":\"ResetTool\"},{\"id\":\"3d62a331-33d9-4c25-8612-dda893f771f9\",\"type\":\"HelpTool\"}]},\"id\":\"deba4899-e12c-4557-8251-6e6234942335\",\"type\":\"Toolbar\"},{\"attributes\":{\"source\":{\"id\":\"d3d89c33-542e-4b5e-a5f4-3797d2d5894b\",\"type\":\"ColumnDataSource\"}},\"id\":\"505e30ae-dec8-441b-8a93-1b8d269979ed\",\"type\":\"CDSView\"},{\"attributes\":{\"callback\":null},\"id\":\"b9be13f6-6817-4543-9e40-63b9ce192600\",\"type\":\"DataRange1d\"},{\"attributes\":{\"data_source\":{\"id\":\"d3d89c33-542e-4b5e-a5f4-3797d2d5894b\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"df90eb0b-1a6d-4e3b-a6d4-b3d0d23c3c2d\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"b0dce9d1-0600-45f5-851c-5e5b052fc0a4\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"505e30ae-dec8-441b-8a93-1b8d269979ed\",\"type\":\"CDSView\"}},\"id\":\"29c7074f-b8ba-4d79-bbe4-24bc40db2bc9\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"line_color\":{\"value\":\"#1f77b4\"},\"line_width\":{\"value\":2},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"bbbb5b6b-b2b3-4f7c-a034-ef04284e6932\",\"type\":\"Line\"},{\"attributes\":{\"callback\":null},\"id\":\"e1b88d03-ee69-4987-b429-d8aac4f348f9\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"842c8533-f82d-40dc-917f-c32b50801efd\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"b6c999d7-215d-45cd-8031-655c7dcd0e31\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"220070e2-6302-4697-91c1-2dfa316c8841\",\"type\":\"BasicTicker\"}],\"root_ids\":[\"0df8d695-d5e7-4c15-be5b-1739152bd2ca\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.7\"}};\n",
       "            var render_items = [{\"docid\":\"d99dc78a-e0c8-4975-b7dc-f7a9b0130435\",\"elementid\":\"5af4ccf3-6a1f-4d7b-973a-f8de11deb631\",\"modelid\":\"0df8d695-d5e7-4c15-be5b-1739152bd2ca\"}];\n",
       "            \n",
       "            Bokeh.embed.embed_items(docs_json, render_items);\n",
       "          };\n",
       "          if (document.readyState != \"loading\") fn();\n",
       "          else document.addEventListener(\"DOMContentLoaded\", fn);\n",
       "        })();\n",
       "      },\n",
       "      function(Bokeh) {\n",
       "      }\n",
       "    ];\n",
       "  \n",
       "    function run_inline_js() {\n",
       "      \n",
       "      if ((root.Bokeh !== undefined) || (force === true)) {\n",
       "        for (var i = 0; i < inline_js.length; i++) {\n",
       "          inline_js[i].call(root, root.Bokeh);\n",
       "        }if (force === true) {\n",
       "          display_loaded();\n",
       "        }} else if (Date.now() < root._bokeh_timeout) {\n",
       "        setTimeout(run_inline_js, 100);\n",
       "      } else if (!root._bokeh_failed_load) {\n",
       "        console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "        root._bokeh_failed_load = true;\n",
       "      } else if (force !== true) {\n",
       "        var cell = $(document.getElementById(\"5af4ccf3-6a1f-4d7b-973a-f8de11deb631\")).parents('.cell').data().cell;\n",
       "        cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "      }\n",
       "  \n",
       "    }\n",
       "  \n",
       "    if (root._bokeh_is_loading === 0) {\n",
       "      console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "      run_inline_js();\n",
       "    } else {\n",
       "      load_libs(js_urls, function() {\n",
       "        console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "        run_inline_js();\n",
       "      });\n",
       "    }\n",
       "  }(window));\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# set up some data\n",
    "x = [1, 2, 3, 4, 5]\n",
    "y = [6, 7, 8, 7, 3]\n",
    "\n",
    "# create a new plot with figure\n",
    "p = figure(plot_width=400, plot_height=400)\n",
    "\n",
    "# add both a line and circles on the same plot\n",
    "p.line(x, y, line_width=2)\n",
    "p.circle(x, y, fill_color=\"white\", size=8)\n",
    "\n",
    "show(p) # show the results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# EXERCISE: create your own plot combining multiple glyphs together\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
